package com.example.csmall.product.preload;

import com.example.csmall.product.service.BrandService;
import com.example.csmall.product.service.CategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class CachePreLoad implements ApplicationRunner {

    @Autowired
    BrandService brandService;
    @Autowired
    CategoryService categoryService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.debug("调用BrandService层中的rebuildCache方法对Brand表中的数据进行缓存预热");
        brandService.rebuildCache();
        log.debug("调用categoryService层中的rebuildCache方法对category表中的数据进行缓存预热");
        categoryService.rebuildCache();
    }



}
